<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Store extends BaseModel
{
    protected $fillable = [
        'name',
        'username',
        'password',
    ];

    public function detail()
    {
        return $this->hasOne(StoreDetail::class);
    }


    public function delete()
    {
//        Cashier::where('store_id',$this->id)->update(['status'=>2]);
        $cashiers = Cashier::where('store_id', $this->id)->select();
        $cashiers->delete();
        // 删除门店时删除当前门店店长账号
        $admin = AdminUser::where('store_id', $this->id)->select();
        $admin->delete();
        // 删除门店详情
        $storeDetail = StoreDetail::where('store_id', $this->id)->select();
        $storeDetail->delete();
        return parent::delete(); // TODO: Change the autogenerated stub
    }
}
